<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}智能竞赛信息平台{% endblock %}</title>
    <!-- 网站图标 -->
    <link rel="icon" type="image/x-icon" href="{{ url_for('static', filename='favicon.ico') }}">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/common.css') }}">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/base.css') }}">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/user-dropdown.css') }}">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/ai-chat.css') }}">
    <!-- Markdown渲染库 -->
    <script src="{{ url_for('static', filename='js/cdn.staticfile.org_marked_4.3.0_marked.min.js') }}"></script>
    <script src="{{ url_for('static', filename='js/ai-chat.js') }}" defer></script>
    <script src="{{ url_for('static', filename='js/base.js') }}" defer></script>

    <!-- 竞赛信息展示 -->
    <script src="{{ url_for('static', filename='js/competition.js') }}" defer></script>
    <link rel="stylesheet" href="{{ url_for('static', filename='css/competition.css') }}">
    
</head>
<body>
    <section class="page-container">
        <div class="navbar">
            <div class="logo">
                <iconify-icon icon="clarity:computer-solid" style="color: #2A5CAA;" width="36"></iconify-icon>
                <span style="font-size: 22px; font-weight: 700; color: #2A5CAA; margin-right: 12px;">竞赛智汇</span>
            </div>
            <div class="nav-links">
                <a href="/" class="nav-link">首页</a>
                <a href="/notifications" class="nav-link">通知中心</a>
                <a href="/chat-history" class="nav-link">对话记录</a>
                <a href="/profile" class="nav-link">个人中心</a>
            </div>
            <div class="user-info" id="userInfoDropdown">
                <div class="user-info-trigger">
                    <span>{{ user.name }}</span>
                    <iconify-icon icon="material-symbols:keyboard-arrow-down" width="20" class="dropdown-arrow"></iconify-icon>
                    
                    <!-- 头像容器 - 优先显示用户头像，没有则显示默认图标 -->
                    <div class="user-avatar">
                        {% if user.avatar_url %}
                            <!-- 使用动态头像 -->
                            <img src="{{ url_for('static', filename=user.avatar_url) }}"
                                 alt="{{ user.name }}"
                                 style="width: 100%; height: 100%; object-fit: cover;">
                        {% else %}
                            <!-- 默认图标 -->
                            <iconify-icon icon="healthicons:ui-user-profile" width="24"></iconify-icon>
                        {% endif %}
                    </div>
                </div>
                
                <!-- 下拉菜单 -->
                <div class="user-dropdown" id="userDropdown">
                    <div class="dropdown-header">
                        <div class="dropdown-user-info">
                            <div class="dropdown-avatar">
                                {% if user.avatar_url %}
                                    <img src="{{ url_for('static', filename=user.avatar_url) }}"
                                         alt="{{ user.name }}"
                                         style="width: 100%; height: 100%; object-fit: cover;">
                                {% else %}
                                    <iconify-icon icon="healthicons:ui-user-profile" width="24"></iconify-icon>
                                {% endif %}
                            </div>
                            <div class="dropdown-user-details">
                                <div class="dropdown-user-name">{{ user.name }}</div>
                                <div class="dropdown-user-id">{{ user.student_id }}</div>
                            </div>
                        </div>
                    </div>
                    
                    <div class="dropdown-menu">
                        <a href="/profile" class="dropdown-item">
                            <iconify-icon icon="material-symbols:person" width="18"></iconify-icon>
                            个人中心
                        </a>
                        <a href="/notifications" class="dropdown-item">
                            <iconify-icon icon="material-symbols:notifications" width="18"></iconify-icon>
                            通知中心
                        </a>
                        <a href="/chat-history" class="dropdown-item">
                            <iconify-icon icon="material-symbols:chat" width="18"></iconify-icon>
                            对话记录
                        </a>
                        <div class="dropdown-divider"></div>
                        <a href="/logout" class="dropdown-item logout-item">
                            <iconify-icon icon="material-symbols:logout" width="18"></iconify-icon>
                            退出登录
                        </a>
                    </div>
                </div>
            </div>
        </div>

        {% block content %}{% endblock %}

    </section>


    <!-- AI气泡 -->
    <div class="ai-bubble" id="chatBubble">
        <svg width="40" height="40" viewBox="2 0 20 20" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false">
            <!-- 气泡主体 -->
            <path fill="#2A5CAA" d="M4 4h16a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-7l-4 3v-3H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z"/>
            <!-- 三个点（重新排列并放大） -->
            <circle cx="8" cy="12" r="1.6" fill="#FFFFFF"/>
            <circle cx="12" cy="12" r="1.6" fill="#FFFFFF"/>
            <circle cx="16" cy="12" r="1.6" fill="#FFFFFF"/>
        </svg>
    </div>

    <!-- 聊天窗口 -->
    <div class="ai-chat" id="chatWindow">
        <div class="chat-header">
            <span id="chatTitle">AI竞赛助手</span>
            <button class="chat-close" id="chatClose">&times;</button>
        </div>
        <div class="chat-messages hide-scrollbar" id="chatMessages">
            <div class="message ai-message">您好！我是竞赛智能助手。请问有什么可以帮您？</div>
        </div>
        <div class="chat-input">
            <input type="text" id="chatInput" placeholder="输入你的问题...">
            <button id="chatSend">发送</button>
        </div>
    </div>
</body>
</html>